Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Serialized Property Regex removal #40

Merged

Conversation

Thundernerd
Copy link
Collaborator

No description provided.

@RoyTheunissen RoyTheunissen self-assigned this Aug 24, 2024
Copy link
Owner

@RoyTheunissen RoyTheunissen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a thing you could do to make it faster, though it's pretty small

private static void ParseFieldStructure(string input, out string fieldName, out int index)
{
int startIndex = input.IndexOf('[');
int endIndex = input.IndexOf(']');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int endIndex = input.IndexOf(']');
int endIndexSearchStart = Mathf.Min(startIndex + 1, input.Length - 1);
int endIndexSearchCount = Mathf.Min(9, input.Length - startIndex - 1);
int endIndex = input.IndexOf(']', endIndexSearchStart, endIndexSearchCount );

The end index is supposed to always be shortly after the start index, right?

So it would be good to start looking right after the start index. You could also limit it to a few characters (say, 8).

Then we have to make sure it doesn't exceed the length of the string because that would throw an ArgumentOutOfRangeException apparently

This would die a horrible death if startIndex is -1 but I think it's supposed to always be there, right?

Maybe using a search count is unnecessary hassle. At the very least you should be able to use a start index though 😄

@RoyTheunissen RoyTheunissen merged commit fe27475 into RoyTheunissen:main Aug 24, 2024
@Thundernerd Thundernerd deleted the fix/serialized_property_regex branch August 24, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants